package com.moli.iov.common.hbase.properties;

import lombok.Data;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;

import static com.moli.iov.common.hbase.constants.HBaseConstant.AUTO_PREFIX;

/**
 *
 * HBase of configuration properties.
 *
 * @author OAK
 * @version 3.0.1
 * @since 2019/12/13 9:56 PM.
 *
 */
@Data
@AutoConfigurationPackage
@ConfigurationProperties(AUTO_PREFIX)
public class HBaseProperties {

    /**
     * HBase client for cluster's zookeeper configuration information.
     */
    private ZookeeperProperties zookeeper;

    /**
     * HBase client remote produce call configuration information.
     */
    private RpcProperties rpc;

    /**
     * HBase client configuration information.
     */
    private ClientProperties client;

    /**
     * Whether enable thread pool.
     */
    private Boolean enableThreadPool;

    /**
     * Whether enable async.
     */
    private Boolean enableAsync;

    /**
     * HBase connection thread pool configuration information.
     */
    private ThreadPoolProperties pool;

    @Data
    public static class ZookeeperProperties {

        private List<String> quorum;

        private ZookeeperPropertyProperties property;

        @Data
        public static class ZookeeperPropertyProperties{

            private Integer clientPort;

        }
    }

    @Data
    public static class RpcProperties{

        /**
         * HBase client remote produce call timeout (i.e. milliseconds).
         */
        private Integer timeout;

    }

    @Data
    public static class ClientProperties{

        /**
         * HBase client operation configuration information.
         */
        private ClientOperationProperties operation;

        /**
         * HBase client scan configuration information.
         */
        private ClientScannerProperties scanner;

        /**
         * HBase client ipc configuration information.
         */
        private ClientIpcProperties ipc;

        @Data
        public static class ClientOperationProperties{

            /**
             * HBase client operation timeout (i.e. milliseconds).
             */
            private Integer timeout;

        }

        @Data
        public static class ClientScannerProperties {

            /**
             * HBase client scan timeout period configuration information.
             */
            private ClientScannerTimeoutProperties timeout;

            @Data
            public static class ClientScannerTimeoutProperties{

                /**
                 * HBase client scan timeout period (i.e. milliseconds).
                 */
                private Integer period;

            }

        }

        @Data
        public static class ClientIpcProperties{

            /**
             * HBase client ipc pool configuration information.
             */
            private ClientIpcPoolProperties pool;

            @Data
            public static class ClientIpcPoolProperties{

                /**
                 * HBase client ipc pool type.
                 */
                private String type;

                /**
                 * HBase client ipc pool size.
                 */
                private Integer size;

            }

        }
    }


    @Data
    public class ThreadPoolProperties {

        /**
         * Core pool size.
         */
        private Integer corePoolSize;

        /**
         * Max pool size.
         */
        private Integer maxPoolSize;

        /**
         * Queue capacity.
         */
        private Integer queueCapacity;

        /**
         * Keep alive seconds.
         */
        private Integer keepAliveSeconds;

        /**
         * Executor policy.
         */
        private String executorPolicy;

    }

}
